package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.service.FileService;
import net.wanho.vo.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
public class FileController {

    private final FileService fileService;

    /**
     * 文件上传请求
     */
    @PostMapping("/upload")
    public AjaxResult upload(MultipartFile file){
        String url = fileService.uploadFile(file);
        return AjaxResult.success("文件上传成功", url);
    }
}
